﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ProjectMeetingStatus.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The project meeting status.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Models.Domain
{
    using System.Collections.Generic;

    using NHibernate.Mapping.ByCode.Conformist;

    using ServiceLibrary.Models.Base;

    /// <summary>
    /// The project meeting status.
    /// </summary>
    public class ProjectMeetingStatus : Entity
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectMeetingStatus"/> class.
        /// </summary>
        public ProjectMeetingStatus()
        {
            this.Demonstrations = new HashSet<ProjectMeetingDemonstration>();
            this.GuidanceAbout = new HashSet<Fund>();
            this.ApplicationAbout = new HashSet<Fund>();
            this.Financing = new HashSet<Fund>();
            this.Roles = new HashSet<ProjectMeetingRole>();
        }

        #endregion

        // Common
        #region Public Properties

        /// <summary>
        /// Gets or sets the application about.
        /// </summary>
        public virtual ICollection<Fund> ApplicationAbout { get; set; }

        /// <summary>
        /// Gets or sets the application about text.
        /// </summary>
        public virtual string ApplicationAboutText { get; set; }

        /// <summary>
        /// Gets or sets the demonstrations.
        /// </summary>
        public virtual ICollection<ProjectMeetingDemonstration> Demonstrations { get; set; }

        // Either NotStarted, Started or Completed 

        // For Status:NotStarted

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        public virtual string Description { get; set; }

        // For Status:Started

        /// <summary>
        /// Gets or sets the financing.
        /// </summary>
        public virtual ICollection<Fund> Financing { get; set; }

        /// <summary>
        /// Gets or sets the financing text.
        /// </summary>
        public virtual string FinancingText { get; set; }

        /// <summary>
        /// Gets or sets the guidance about.
        /// </summary>
        public virtual ICollection<Fund> GuidanceAbout { get; set; }

        /// <summary>
        /// Gets or sets the guidance about text.
        /// </summary>
        public virtual string GuidanceAboutText { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether is external.
        /// </summary>
        public virtual bool IsExternal { get; set; }

        /// <summary>
        /// Gets or sets the patent name.
        /// </summary>
        public virtual string PatentName { get; set; }

        /// <summary>
        /// Gets or sets the roles.
        /// </summary>
        public virtual ICollection<ProjectMeetingRole> Roles { get; set; }

        /// <summary>
        /// Gets or sets the status of project.
        /// </summary>
        public virtual string StatusOfProject { get; set; }

        // for status: R&D, non-R&D

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        public virtual ProjectType Type { get; set; }

        /// <summary>
        /// Gets or sets the project meeting type.
        /// </summary>
        public virtual Enums.ProjectMeetingStatusType StatusType { get; set; }

        #endregion
    }

    /// <summary>
    /// The project meeting status mapping.
    /// </summary>
    public class ProjectMeetingStatusMapping : ClassMapping<ProjectMeetingStatus>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectMeetingStatusMapping"/> class.
        /// </summary>
        public ProjectMeetingStatusMapping()
        {
            this.Property(x => x.PatentName);
            this.Set(x => x.Demonstrations, c => { }, m => m.ManyToMany());

            this.Set(x => x.GuidanceAbout, c => { }, m => m.ManyToMany());
            this.Property(x => x.GuidanceAboutText, m => m.Length(int.MaxValue / 2));

            this.Set(x => x.ApplicationAbout, c => { }, m => m.ManyToMany());
            this.Property(x => x.ApplicationAboutText, m => m.Length(int.MaxValue / 2));

            this.Property(x => x.StatusOfProject);

            this.Property(x => x.Description, m => m.Length(int.MaxValue / 2));

            this.Property(x => x.IsExternal);
            this.Set(x => x.Financing, c => { }, m => m.ManyToMany());
            this.Property(x => x.FinancingText, m => m.Length(int.MaxValue / 2));
            this.Set(x => x.Roles, c => { }, m => m.ManyToMany());
            this.ManyToOne(x => x.Type);
            this.Property(x => x.StatusType);
        }   

        #endregion
    }
}